package demo;

import java.util.HashMap;

public class UnsafeHashMapExample {
    public static void main(String[] args) throws InterruptedException {
        final HashMap<String, Integer> map = new HashMap<>();

        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                map.put(Integer.toString(i), i);
            }
        });

        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                map.put(Integer.toString(i), i);
            }
        });

        thread1.start();
        thread2.start();

        thread1.join();
        thread2.join();

        System.out.println("Map size: " + map.size());
    }
}
